package br.cin.ufpe.corba.namingservice.binding;

import java.util.List;

public class BindingIterator {

	private List<Binding> list;
	
	int index;
	
	public BindingIterator(BindingList list) {
		this.index = 0;
		this.list = list.getInnerList();
	}
	
	public boolean has_next_one() {
		return (this.index < this.list.size());
	}
	
	public Binding next_one() {
		if(this.index < this.list.size()) {						
			return this.list.get(index++);
		}
		return null;
	}
	
	public BindingList next_n(int how_many) {
		if(this.index + how_many < this.list.size()) {			
			BindingList retval = new BindingList(this.list.subList(index, index+how_many));
			index += how_many;
			return retval;
		}
		return null;
	}
	
}
